import Vue from "vue";
import VueRouter from "vue-router";
const Home = () => import('views/home/home')
const Category = () => import('views/category/category')
const Cart = () => import('views/cart/cart')
const Profile = () => import('views/profile/profile')
const Detail = () => import('views/detail/Detail')
const Login = () => import('views/login/login')
const Text = () => import('views/login/childComp/text')
const Password = () => import('views/login/childComp/password')
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location, onResolve, onReject) {
    if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
    return originalPush.call(this, location).catch(err => err)
}
Vue.use(VueRouter)
const router = new VueRouter({
    routes: [
        {
            path: '/',
            redirect: '/home'
        }, {
            path: '/home',
            component: Home,
            meta: { footShow: true }

        },
        {
            path: '/category',
            component: Category,
            meta: { footShow: true }

        },
        {
            path: '/cart',
            component: Cart,
            meta: { footShow: true }

        },
        {
            path: '/profile',
            component: Profile,
            meta: { footShow: true }

        },
        {
            path: '/detail/:iid',
            component: Detail,


        }
        ,
        {
            path: '/login',
            component: Login,
            children: [
                {
                    path: 'text',
                    component: Text
                }, {
                    path: 'password',
                    component: Password
                }
            ]

        }
    ],
    mode: 'history'
})

export default router